package lunbo;

import com.common.model.Video;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

public class LunBo extends Controller {

    public void add() {
        boolean b = getModel(Video.class, "").save();
        if (b) {
            renderJson("ok");
        } else {
            renderJson("err");
        }
    }

    public void del() {
        boolean b = getModel(Video.class).deleteById(getParaToInt("id"));
        if (b) {
            renderJson("ok");
        } else {
            renderJson("err");
        }
    }


    public void list() {
        String sql = "SELECT url FROM pic";
        List<Record> list = Db.find(sql);
        if (list.size() > 0) {
            renderJson("msg",list);
        } else {
            renderJson("msg","无图无真相");
        }

    }

    public void list2() {
        String sql = "SELECT url FROM pic";
        List<Record> list = Db.find(sql);
        if (list.size() > 0) {
            renderJson(list);
        } else {
            renderJson("无图无真相");
        }

    }

}
